package org.tczs93.commonreadwrite.config;

/**
 * @author ：tao.li
 * @description：
 * @date ：Created in 2021/8/23 15:24
 */
public class RouteDataSource {


    /**
     * dbKey线程安全容器
     */
    private static ThreadLocal<String> holder = new ThreadLocal<>();


    public static String getDbKey(){
        String dbKey = holder.get();
        holder.remove();
        return dbKey;
    }

    /**
     * 设置dbKey
     *
     * @param dbKey
     */
    public static void setDbKey(RouteDataSourceKeyEnum dbKey) {
        holder.set(dbKey.name());
    }
}
